// app.js
import i18n from './utils/i18n/index';

App({
  globalData: {
    i18n: i18n,
    userInfo: null
  },
  
  onLaunch() {
    // Initialize language from storage or system settings
    const storedLanguage = wx.getStorageSync('userLanguage');
    if (!storedLanguage) {
      // Try to get system language if no stored preference
      const systemInfo = wx.getSystemInfoSync();
      const systemLanguage = systemInfo.language;
      
      // Set initial language based on system (simplified approach)
      if (systemLanguage && systemLanguage.startsWith('zh')) {
        i18n.setLanguage('zh');
      } else {
        i18n.setLanguage('en');
      }
    }
  },
  
  // Helper method to get translations
  t(key) {
    return this.globalData.i18n.t(key);
  }
})